package com.controller.lzj;

import com.bean.lzj.Car;
import com.bean.lzj.TruckSpace;
import com.bean.lzj.Result;

import com.bean.lzj.Materiel;
import com.dao.lzj.CarDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLException;
import java.util.List;

/**
 * 处理车辆信息
 */
@Controller
@RequestMapping("/LzjPage/")
public class CarController {
    /**\
     * 查询车位信息
     *
     * @throws SQLException
     */
    @Autowired


    /**
     * 查询全部车辆信息
      * @return
     * @throws SQLException
     */
    @RequestMapping(value = "getclxx",method = RequestMethod.GET)
    @ResponseBody
    public List<Car> getcarl() throws SQLException {
        List<Car> cl = CarDao.getcarl();
        return cl;
    }

    /**
     * 根据id删除车位信息
     * @param ccid
     * @return
     */
    @RequestMapping("deleteClxx")
    @ResponseBody
    public Result deleteClxxById(int ccid ,int carid) throws SQLException {
        System.out.println(ccid);
        boolean result = CarDao.deleteClxxById(ccid,carid);
        Result rs = new Result();
        rs.setOk(result);
        return rs;
    }

    /**
     * 综合查询数据
     * @return
     * @throws SQLException
     */
    @RequestMapping(value = "zhcx",method =RequestMethod.POST)
    @ResponseBody
    public List<Car> getzhxxcx(String czname, String czsjh, String cphm) throws SQLException {
        List<Car> cl = CarDao.getzhxxcx(czname,czsjh,cphm);
        return cl;
    }

    @RequestMapping("chaxuncheliang")
    @ResponseBody
    public List<TruckSpace> getzhxxcx(int pid) throws SQLException {
        System.out.println(pid);
        List<TruckSpace> cl = CarDao.getzhxxcx(pid);
        return cl;
    }


    /**
     * 查询住户信息
     *
     */
    @RequestMapping(value = "addzhuhu",method = RequestMethod.GET)
    @ResponseBody
    public List<Materiel> addzhuhuxinxi() throws SQLException {
        List<Materiel> zh = CarDao.addzhuhuxinxi();
        return zh;
    }


    /**
     * 添加信息
     * @param zhxm
     * @param cwh
     * @param tckh
     * @param sjh
     * @param xszh
     * @param cph
     * @return
     * @throws SQLException
     */
    @RequestMapping(value = "tianjiaclxx",method = RequestMethod.POST)
    @ResponseBody
public Result tianjiaclxx(String zhxm,String cwh,String tckh,String sjh,String xszh,String cph ) throws SQLException {
    System.out.println(zhxm);
    boolean result = CarDao.tianjiaclxx(zhxm,cwh,tckh,sjh,xszh, cph);
    Result rs = new Result();
    rs.setOk(result);
    return rs;
}
}
